package com.sun.androidexerciseproject.widget.adapter;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

import com.sun.androidexerciseproject.widget.util.LogUtil;

import java.util.List;

/**
 * Created by Administrator on 2016/6/3 0003.
 */

public class ViewPagerAdapter extends PagerAdapter {
    private List<String> mList;
    private List<View> mViews;
    public ViewPagerAdapter(List<String> list,List<View> views) {
        mViews = views;
        mList = list;
    }
    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        LogUtil.log("isViewFromObject");
        return (view == object);
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        View view = mViews.get(position);
        container.addView(view);
        return view;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return mList.get(position);
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView(mViews.get(position));
    }
}
